<?php
class SysstatAction extends BaseAction
{
	function index()
	{
		$Dao = D("Sysstat"); 
		$count = $Dao->count(); 
		import("ORG.Util.Page"); 
		if(!empty($_REQUEST["listRows"])) { 
			$listRows = $_REQUEST["listRows"]; 
			}else{ 
			$listRows = 20; 
		} 
		$p = new Page($count,$listRows); 
 
		$field = "*"; 
		$list = $Dao->findAll("",$field,"id desc",$p->firstRow.",".$p->listRows); 
		$page = $p->show(); 
		$this->assign("list",$list); 
		$this->assign("page",$page); 
		$this->display(); 
	}

	function add() 
	{ 
		// 添加内容的页面 
		$this->display(); 
	} 

	function insert() 
	{ 
		// 保存添加的数据
		$Dao = D("Sysstat"); 
		$vo = $Dao->create(); 
		if(false === $vo) { 
	 		$this->error($Dao->getError()); 
		} 
 
		$rs = $Dao->add(); 
		if($rs){ 
			$this->assign("jumpUrl",__URL__); 
			$this->success("添加数据成功!"); 
		}else{ 
			$this->error("添加数据失败"); 
		} 
	}

	function edit() 
	{ 
		// 编辑页面 
		$Dao = D("Sysstat"); 
		$vo = $Dao->find("id=".$_GET["id"]); 
		if($vo === false) 
		{ 
			$this->assign("jumpUrl",__URL__); 
			$this->error("Non-existed record"); 
		} 
		 
		$this->assign("vo",$vo); 
		$this->display(); 
	} 

	function update() 
	{ 
		// 保存编辑过的数据 
		$Dao = D("Sysstat"); 
		$vo = $Dao->create("","edit");
		if(false === $vo) { 
	 		$this->error($Dao->getError()); 
		} 
 
		$rs = $Dao->save(); 
		if($rs){ 
			$this->assign("jumpUrl",__URL__); 
			$this->success("保存修改成功!"); 
		}else{ 
			$this->error("保存修改失败"); 
		} 
	}

	function delete() 
	{ 
		// 根据id删除指定的记录
		$Dao = D("Sysstat"); 
		$id = $_REQUEST["id"]; 
		if(isset($id)) { 
			$result = $Dao->getById($id); 
			if(!$result) { 
				$this->error("Non-existed record!"); 
			} 
			if($Dao->deleteById($id)){ 
				$this->assign("jumpUrl",__URL__); 
				$this->success("删除数据成功"); 
			}else { 
				$this->error("删除数据失败"); 
			}
		}else { 
			$this->error("非法操作"); 
		} 
	}
}
?>